# -*- codeing = utf-8 -*-
# @Time: 2023/6/15 9:42
# @Author: caoyi
# @File: login_api.py
# @Software: PyCharm

from tests.litemall_api.base_api import BaseApi, BASE_URL


class LoginApi(BaseApi):
    def login(self):
        # 完成登录
        login_json = {
            "username": "hogwarts",
            "password": "test12345",
            "code": ""
        }
        login_url = f"{BASE_URL}/admin/auth/login"
        # proxies=proxys,verify=False走代理，忽略校验
        login_resp = self.myrequest("post", login_url, json=login_json)
        # 请求头
        # self.headers = {
        #     "x-litemall-admin-token":self.token
        # }
        # 拼接包含登录信息的请求头
        self.session.headers = {
            "x-litemall-admin-token": login_resp.json()['data']['token']
        }